package main.java.game.event;


import java.util.Random;

import main.java.game.Dice;
import main.java.game.DiceImpl;
import main.java.game.Game;
import main.java.game.item.Treasure;

public class Robbers extends Event {

	public Robbers(String name, Boolean subscribed){
		super(name,subscribed);
		
	}
	public void takeEffect(Game game){
		super.takeEffect(game);
		Dice dice = new DiceImpl();
		Integer diceRoll=dice.roll();
		if(diceRoll.equals(1) || diceRoll.equals(2)){
			Random random = new Random();
			if(game.getPlayer().getTreasures().size()>0){	
				Integer index = Math.abs(random.nextInt()%game.getPlayer().getTreasures().size());
				Treasure treasure=game.getPlayer().getTreasures().get(index);
				game.getTreasures().get(treasure.getLevel()).add(treasure);
				game.getPlayer().getTreasures().remove(treasure);
				System.out.println("You loose your treasure: !"+treasure.getName()+"\n");
			}
		}
	}

}
